package com.itheima.sh.Test;

import java.util.ArrayList;

public class Test07_01 {
    public static ArrayList<Phone> find(ArrayList<Phone> list, int price, String color) {
        ArrayList<Phone> newlist = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Phone p = list.get(i);
            int price1 = p.getPrice();
            String colour1 = p.getColour();
            if (price1 > price && colour1.equals(color)) {
                newlist.add(p);
            }
        }
        return newlist;
    }

    public static void main(String[] args) {
        Phone phone = new Phone("小米", 3999, "蓝色");
        Phone phone1 = new Phone("oppo", 3999, "黑色");
        Phone phone2 = new Phone("vivo", 4999, "黑色");
        Phone phone3 = new Phone("华为", 5999, "白色");
        Phone phone4 = new Phone("坚果", 2999, "白色");
        ArrayList<Phone> phones = new ArrayList<>();
        phones.add(phone);
        phones.add(phone1);
        phones.add(phone2);
        phones.add(phone3);
        phones.add(phone4);

        ArrayList<Phone> newlist = find(phones, 3000, "黑色");
        for (int i = 0; i < newlist.size(); i++) {
            Phone phone5 = newlist.get(i);
            String brand = phone5.getBrand();
            String colour = phone5.getColour();
            int price = phone5.getPrice();
            System.out.println(brand + "--" + colour + "--" + "--" + price);
        }

    }
}
